{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: mysqlclient in /usr/local/lib/python3.8/site-packages (2.0.3)\n",
      "Requirement already satisfied: sqlalchemy in /usr/local/lib/python3.8/site-packages (1.3.22)\n",
      "Requirement already satisfied: jupyter_contrib_nbextensions in /usr/local/lib/python3.8/site-packages (0.5.1)\n",
      "Requirement already satisfied: jupyter-highlight-selected-word>=0.1.1 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (0.2.0)\n",
      "Requirement already satisfied: notebook>=4.0 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (6.1.6)\n",
      "Requirement already satisfied: pyyaml in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (5.3.1)\n",
      "Requirement already satisfied: nbconvert>=4.2 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (6.0.7)\n",
      "Requirement already satisfied: lxml in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (4.6.2)\n",
      "Requirement already satisfied: jupyter-nbextensions-configurator>=0.4.0 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (0.4.1)\n",
      "Requirement already satisfied: traitlets>=4.1 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (5.0.5)\n",
      "Requirement already satisfied: jupyter-latex-envs>=1.3.8 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (1.4.6)\n",
      "Requirement already satisfied: jupyter-contrib-core>=0.3.3 in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (0.3.3)\n",
      "Requirement already satisfied: ipython-genutils in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (0.2.0)\n",
      "Requirement already satisfied: tornado in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (6.1)\n",
      "Requirement already satisfied: jupyter-core in /usr/local/lib/python3.8/site-packages (from jupyter_contrib_nbextensions) (4.7.0)\n",
      "Requirement already satisfied: terminado>=0.8.3 in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (0.9.1)\n",
      "Requirement already satisfied: jinja2 in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (2.11.2)\n",
      "Requirement already satisfied: Send2Trash in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (1.5.0)\n",
      "Requirement already satisfied: prometheus-client in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (0.9.0)\n",
      "Requirement already satisfied: nbformat in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (5.0.8)\n",
      "Requirement already satisfied: jupyter-client>=5.3.4 in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (6.1.7)\n",
      "Requirement already satisfied: pyzmq>=17 in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (20.0.0)\n",
      "Requirement already satisfied: argon2-cffi in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (20.1.0)\n",
      "Requirement already satisfied: ipykernel in /usr/local/lib/python3.8/site-packages (from notebook>=4.0->jupyter_contrib_nbextensions) (5.4.2)\n",
      "Requirement already satisfied: testpath in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.4.4)\n",
      "Requirement already satisfied: jupyterlab-pygments in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.1.2)\n",
      "Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.5.1)\n",
      "Requirement already satisfied: pygments>=2.4.1 in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (2.7.3)\n",
      "Requirement already satisfied: pandocfilters>=1.4.1 in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (1.4.3)\n",
      "Requirement already satisfied: entrypoints>=0.2.2 in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.3)\n",
      "Requirement already satisfied: defusedxml in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.6.0)\n",
      "Requirement already satisfied: mistune<2,>=0.8.1 in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (0.8.4)\n",
      "Requirement already satisfied: bleach in /usr/local/lib/python3.8/site-packages (from nbconvert>=4.2->jupyter_contrib_nbextensions) (3.2.1)\n",
      "Requirement already satisfied: ipython in /usr/local/lib/python3.8/site-packages (from jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (7.19.0)\n",
      "Requirement already satisfied: setuptools in /usr/local/lib/python3.8/site-packages (from jupyter-contrib-core>=0.3.3->jupyter_contrib_nbextensions) (50.3.2)\n",
      "Requirement already satisfied: ptyprocess; os_name != \"nt\" in /usr/local/lib/python3.8/site-packages (from terminado>=0.8.3->notebook>=4.0->jupyter_contrib_nbextensions) (0.7.0)\n",
      "Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.8/site-packages (from jinja2->notebook>=4.0->jupyter_contrib_nbextensions) (1.1.1)\n",
      "Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in /usr/local/lib/python3.8/site-packages (from nbformat->notebook>=4.0->jupyter_contrib_nbextensions) (3.2.0)\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.8/site-packages (from jupyter-client>=5.3.4->notebook>=4.0->jupyter_contrib_nbextensions) (2.8.1)\n",
      "Requirement already satisfied: six in /usr/local/lib/python3.8/site-packages (from argon2-cffi->notebook>=4.0->jupyter_contrib_nbextensions) (1.15.0)\n",
      "Requirement already satisfied: cffi>=1.0.0 in /usr/local/lib/python3.8/site-packages (from argon2-cffi->notebook>=4.0->jupyter_contrib_nbextensions) (1.14.4)\n",
      "Requirement already satisfied: appnope; platform_system == \"Darwin\" in /usr/local/lib/python3.8/site-packages (from ipykernel->notebook>=4.0->jupyter_contrib_nbextensions) (0.1.2)\n",
      "Requirement already satisfied: async-generator in /usr/local/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert>=4.2->jupyter_contrib_nbextensions) (1.10)\n",
      "Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.8/site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert>=4.2->jupyter_contrib_nbextensions) (1.4.3)\n",
      "Requirement already satisfied: packaging in /usr/local/lib/python3.8/site-packages (from bleach->nbconvert>=4.2->jupyter_contrib_nbextensions) (20.8)\n",
      "Requirement already satisfied: webencodings in /usr/local/lib/python3.8/site-packages (from bleach->nbconvert>=4.2->jupyter_contrib_nbextensions) (0.5.1)\n",
      "Requirement already satisfied: jedi>=0.10 in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (0.18.0)\n",
      "Requirement already satisfied: decorator in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (4.4.2)\n",
      "Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (3.0.8)\n",
      "Requirement already satisfied: backcall in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (0.2.0)\n",
      "Requirement already satisfied: pexpect>4.3; sys_platform != \"win32\" in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (4.8.0)\n",
      "Requirement already satisfied: pickleshare in /usr/local/lib/python3.8/site-packages (from ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (0.7.5)\n",
      "Requirement already satisfied: pyrsistent>=0.14.0 in /usr/local/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->notebook>=4.0->jupyter_contrib_nbextensions) (0.17.3)\n",
      "Requirement already satisfied: attrs>=17.4.0 in /usr/local/lib/python3.8/site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->notebook>=4.0->jupyter_contrib_nbextensions) (20.3.0)\n",
      "Requirement already satisfied: pycparser in /usr/local/lib/python3.8/site-packages (from cffi>=1.0.0->argon2-cffi->notebook>=4.0->jupyter_contrib_nbextensions) (2.20)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.8/site-packages (from packaging->bleach->nbconvert>=4.2->jupyter_contrib_nbextensions) (2.4.7)\n",
      "Requirement already satisfied: parso<0.9.0,>=0.8.0 in /usr/local/lib/python3.8/site-packages (from jedi>=0.10->ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (0.8.1)\n",
      "Requirement already satisfied: wcwidth in /usr/local/lib/python3.8/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython->jupyter-latex-envs>=1.3.8->jupyter_contrib_nbextensions) (0.2.5)\n",
      "Enabling notebook extension python-markdown/main...\n",
      "      - Validating: \u001b[32mOK\u001b[0m\n",
      "The sql extension is already loaded. To reload it, use:\n",
      "  %reload_ext sql\n"
     ]
    }
   ],
   "source": [
    "!pip3 install mysqlclient sqlalchemy jupyter_contrib_nbextensions\n",
    "!jupyter contrib nbextension install --user\n",
    "!jupyter nbextension enable python-markdown/main\n",
    "%load_ext sql\n",
    "%sql mysql://root@localhost/napkin"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " * mysql://root@localhost/napkin\n",
      "1 rows affected.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<table>\n",
       "    <tr>\n",
       "        <th>id</th>\n",
       "        <th>updated_at</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "        <td>1100000</td>\n",
       "        <td>2020-12-17 06:26:40</td>\n",
       "    </tr>\n",
       "</table>"
      ],
      "text/plain": [
       "[(1100000, datetime.datetime(2020, 12, 17, 6, 26, 40))]"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = %sql SELECT id, updated_at FROM `table` LIMIT 1;\n",
    "result"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "variables": {
     "result[0][0]": "1100000"
    }
   },
   "source": [
    "*Hey*\n",
    "\n",
    "This is pretty cool {{result[0][0]}}"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
